package com.lovo.roomProject.room.service.impl;

import com.lovo.roomProject.pojo.CutPageBean;
import com.lovo.roomProject.pojo.RoomDO;
import com.lovo.roomProject.pojo.RoomSetDO;
import com.lovo.roomProject.room.dao.RoomDAO;
import com.lovo.roomProject.room.dao.RoomSetDAO;
import com.lovo.roomProject.room.dao.impl.RoomDAOImpl;
import com.lovo.roomProject.room.dao.impl.RoomSetDAOImpl;
import com.lovo.roomProject.room.service.RoomService;
import com.lovo.roomProject.room.service.RoomSetService;

public class RoomSetServiceImpl implements RoomSetService {
    RoomSetDAO roomSetDAO = new RoomSetDAOImpl();
    RoomDAO roomDAO = new RoomDAOImpl();

    @Override
    public CutPageBean listRoomsSetByPage(int current, int roomID) {
        return roomSetDAO.listRoomsSetByPage(current, roomID, null);
    }

    @Override
    public RoomSetDO getRoomSetById(int id) {
        return roomSetDAO.getRoomSetById(id);
    }

    @Override
    public void insert(RoomSetDO roomSetDO) {
        roomSetDAO.insert(roomSetDO);


    }

    @Override
    public void update(RoomSetDO roomSetDO) {
        roomSetDAO.update(roomSetDO);
        CutPageBean cutPageBean = roomSetDAO.listRoomsSetByPage(1, roomSetDO.getRoomId(), "未处理");
        if (cutPageBean.getCount() == 0) {
            RoomDO roomDO = roomDAO.getById(roomSetDO.getRoomId());
            roomDO.setStatus("正常");
            roomDAO.update(roomDO);
        }


    }
}
